package com.source.multithread.reentrantllock;

import java.io.PrintWriter;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @Author wengqy
 * @Date 2020/12/30
 */
public class ReentrantLockDemo {
    static final  int n=0;
    public static void main(String[] args) throws InterruptedException {
      final  int num=0;
       int  snum= num+3;
       snum++;
       snum++;
       snum++;
      int e=  snum++;
        System.out.println(num);
        System.out.println(snum);
       /* Data  data = new Data();
        new Thread(()->{
            data.add();
            try {
                TimeUnit.SECONDS.sleep(2);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        ,"t1").start();


        Thread.sleep(2000);
        System.out.println("main-------");*/

    }
}

class Data{
    private  int num ;

    public  void add(){
        ReentrantLock lock = new ReentrantLock(true);
        lock.lock();
        try{
            num++;
            System.out.println("num:"+num);
        }catch (Exception e){
            System.out.println("exceptuon......");
        }
        finally{
            lock.unlock();
        }

    }
}